package test;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

public class Main extends JFrame{   
	public Main() 
	{      
		JTable table = new JTable(100, 5);    
		TableColumn tm = table.getColumnModel().getColumn(0);     
		tm.setCellRenderer(new ColorColumnRenderer(Color.lightGray, Color.blue));    
		getContentPane().add(new JScrollPane(table));      
 addWindowListener(new WindowAdapter() {         
	 public void windowClosing(WindowEvent we) 
	 {            System.exit(0);         }      });
 }   
	public static void main(String [] args) 
	{    
	Main main = new Main();  
	main.setSize(400, 400);     
	main.setVisible(true);   } 
	} 
/*** Applied background and foreground color to single column of a JTable* in order to distinguish it apart from other columns.*/ 
class ColorColumnRenderer extends DefaultTableCellRenderer {
  
	Color bkgndColor, fgndColor; 	 
  public ColorColumnRenderer(Color bkgnd, Color foregnd)
  	{     
	  super();      
	  bkgndColor = bkgnd;    
	  fgndColor = foregnd;   } 
  public Component getTableCellRendererComponent	
	   (JTable table, Object value, boolean isSelected,	
			   boolean hasFocus, int row, int column)   
	   {      
	  Component cell = super.getTableCellRendererComponent 
		   (table, value, isSelected, hasFocus, row, column);    
	   cell.setBackground( bkgndColor );   
	   cell.setForeground( fgndColor );    
	   return cell;   
	   }
  }